import 'package:flutter/material.dart';

class HouseItem extends StatefulWidget {
  const HouseItem({super.key, required this.houseList});

  final Map houseList;

  @override
  State<HouseItem> createState() => _HouseItemState();
}

class _HouseItemState extends State<HouseItem> {
  // 审核状态 1审核中 2审核成功 3审核失败
  List<String> status = [
    '',
    '审核中', // 1
    '审核成功', // 2
    '审核失败', // 3
  ];

  // 审核状态 1审核中(蓝色) 2审核成功(绿色) 3审核失败(红色)
  List<Color> statusColor = [
    Colors.white,
    Colors.blue, // 1
    Colors.green, // 2
    Colors.red, // 3
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(10),
      decoration: const BoxDecoration(
        color: Colors.white,
      ),
      child: Column(
        children: [
          Row(
            children: [
              Expanded(child: Text(widget.houseList['point'])),
              const Spacer(),
              Container(
                padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 5),
                decoration: BoxDecoration(
                  color: statusColor[widget.houseList['status']],
                  borderRadius: BorderRadius.circular(5),
                ),
                child: Text(
                  status[widget.houseList['status']],
                  style: const TextStyle(
                    color: Colors.white,
                  ),
                ),
              )
            ],
          ),
          const SizedBox(height: 15),
          Row(
            children: [
              Text(
                widget.houseList['building'],
                style: const TextStyle(color: Colors.grey),
              ),
              const Spacer(),
              Expanded(
                child: Text(
                  widget.houseList['room'],
                  textAlign: TextAlign.right,
                ),
              ),
            ],
          ),
          const SizedBox(height: 15),
          Row(
            children: [
              const Text(
                '业主',
                style: TextStyle(color: Colors.grey),
              ),
              const Spacer(),
              Expanded(
                child: Text(
                  widget.houseList['name'],
                  textAlign: TextAlign.right,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
